<template>
    <div class="borderHead">
      <div class="imgBorderHead">
        <img src="" v-if="item.cover==null"/>
        <img :src="this.$DEV_ENV_API+'/api/'+item.cover" v-else class="headImgHead">
      </div>
      <div class="queenBorderHead" :style="queenStyle">
        <img :src="queenImg" class="queenImg">
      </div>
      <div class="nameHead">
        <span>{{item.name}}</span>
      </div>
      <div class="quantityHead">
        <span>{{item.votesNum}}票</span>
      </div>
    </div>
</template>

<script>
    export default {
      name: "rankHeadImg",
      props:["item"],
      watch:{
        item(newVal){
          this.item = newVal;
          if (newVal.candidateOrder == 1) {
            this.queenImg = require( '../assets/rank/1_icon@3x.png');
            this.queenStyle.width = "45px";
            this.queenStyle.height = "45px";
          }
          else if (newVal.candidateOrder == 2) {
            this.queenImg = require( '../assets/rank/2_icon@3x.png')
          }
          else {
            this.queenImg = require( '../assets/rank/3_icon@3x.png')
          }
        }
      },
      data(){
        return{
          queenImg:'',
          queenStyle:{width: "40px",
            height: "40px"}
        }
      },
      mounted() {
        let vm = this;
        if (vm.item.candidateOrder == 1) {
          vm.queenImg = require( '../assets/rank/1_icon@3x.png');
          vm.queenStyle.width = "45px";
          vm.queenStyle.height = "45px";

        }
        else if (vm.item.candidateOrder == 2) {
          vm.queenImg = require( '../assets/rank/2_icon@3x.png')
        }
        else {
          vm.queenImg = require( '../assets/rank/3_icon@3x.png')
        }

      },
    }
</script>

<style scoped>
  .borderHead{
    height: 150px;
    width: 112px;
    position: relative;
  }
  .imgBorderHead{
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: #FFFFFF;
    margin-top: 16px;
    margin-left: 16px;
  }
  .headImgHead{
    width: 76px;
    height: 76px;
    border-radius: 20px;
    margin-left: 2px;
    margin-top: 2px;
    object-fit: cover;
  }
  .queenBorderHead{
    position: absolute;
    right: 0;
    top: 0;
  }
  .queenImg{
    width: 100%;
    height: 100%;

  }
  .nameHead{
    margin-top: 5px;
    text-align: center;
    color: #FFFFFF;
    font-size: 13px;
    font-family: PingFang-SC-Medium;
  }
  .quantityHead{
    margin-top: 10px;
    text-align: center;
    color: #ED60B1;
    font-size: 13px;
    font-family: PingFang-SC-Medium;
  }
</style>
